<?php require_once 'header.php';
require "backend/Employees.php"; 
?>

	<div id = "pagecontent">
	<?php
		if(isset($_POST['Name']))
		{
			$name = ($_POST['Name']);
			$password = ($_POST['Password']);
			if($name == "" || $password == "")
			{
				echo "<font size=3 color=red><b>Not all fields were entered</b><p/></font><br/>";
			}
			else
			{
				$login = new Employee();
				$employee = $login->getEmployee($name,$password);
			
				$username = $employee->getName();
				$userpass = $employee->getPassword();
				if($username == $name && $password == $userpass)
				{
					$_SESSION['employee'] = serialize($employee);
					echo "<script language='JavaScript'>window.location.href='Jobs.php'</script>";
				}
				else {
					echo "<font size='3' color='red'><b>Name and password is incorrect</b><p/></font><br/>";
				}
			}
		}

	if(isset($_SESSION['employee']))
	{
		echo "<font size='3' color='green'><b>You are already signed in please click <a href='Jobs.php'>here.</a></font>";
	}
	else
	{
		
	
	?>
		<h1>EMPLOYEE LOGIN</h1>
		<form action="Employee.php" method="post">
		<fieldset>
		<br><br>
		<div id = "Name">
			<font color = "red" size = "3">Name : <p/></font>
			<input  name="Name" type="text">
			
		</div>
		<div id = "Password">
			<font color = "red" size = "3">Password : <p/></font>
			<input  name="Password" type="password">
	     
		</div>
		
		<p><input type="submit" value="Log On" /></p>
		</fieldset>
		</form>
	</div>

<?php } 
require_once 'footer.php';?>